package common;


public class JfcHeatTools {

	
	public static double[][] convertMatrixToJfcFormat(double[][] map, double[] scaleK0, double[] scaleRT, double cutoff){
		long startTime = System.currentTimeMillis();
		
		int count = 0;
		for (int i = 0; i < map.length; i++) {
			for (int j = 0; j < map[i].length; j++) {
				if (map[i][j] > cutoff) {
					count++;
				}
			}
		}

		double[][] jfcmap = new double[3][count];
		int idx = 0;
		for (int i = 0; i < map.length; i++) {
			for (int j = 0; j < map[0].length; j++) {
				if (map[i][j] > cutoff) {
					jfcmap[0][idx] = scaleK0[i];
					jfcmap[1][idx] = scaleRT[j];
					jfcmap[2][idx] = map[i][j];
					idx++;

				}
			}
		}
		long endTime = System.currentTimeMillis();
		System.out.println("convertMatrixToJfcFormat took " + (endTime - startTime) + " milliseconds.");
		return jfcmap;
	}

	public static double[][] yAlignJfcMap(double[][] jfcmap,double alignment){
		double[][] alignedJFCmap = new double[jfcmap.length][jfcmap[0].length];
		for (int i = 0; i < jfcmap[0].length; i++) {
			alignedJFCmap[0][i] = jfcmap[0][i];
			alignedJFCmap[2][i] = jfcmap[2][i];
			alignedJFCmap[1][i] = jfcmap[1][i] * alignment;
		}
		return alignedJFCmap;
	}
	
}
